clear all

*set working directory
use "data_pilot.dta", replace

*attention
rename BPAQ_2 checkgrid
recode checkgrid 1=1 *=0
tab checkgrid

gen checkindex=(checkview+checkgrid)/2
gen satisficingindex=(checkindex*-1)+1
recode satisficingindex .5/1=1, gen(satisficingindex_di)

*low incidence
recode lowincidence* (.=0)
sum lowincidence*
alpha lowincidence*, item casewise gen(Lowincidence)

replace trolling=(trolling-1)/4
gen Trollindex=(trolling+Lowincidence)/2
gen Trollindex_di=0
replace Trollindex_di=1 if trolling>.25
replace Trollindex_di=1 if Lowincidence>.25


*PID
gen PID=pid
recode PID 1=2 2=6 3/4=4
recode PID 2=1 if pidd==1
recode PID 6=7 if pidr==1
recode PID 4=3 if pidi==1
recode PID 4=5 if pidi==2

gen ideoext=(abs(ideo-4))/3

*PID social
recode repidentity* demidentity* (1=4) (2=3) (3=2) (4=1)
forval x=1/4 {
	egen pididentity`x'=rowfirst(repidentity_`x' demidentity_`x')
}
alpha pididentity*, item casewise gen(PSIDext)
replace PSIDext=(PSIDext-1)/3

alpha repidentity*, item casewise gen(PSIDr)
alpha demidentity*, item casewise gen(PSIDd)
replace PSIDr=(PSIDr-1)/3
replace PSIDd=(PSIDd-1)/-3
egen PSID=rowfirst(PSIDd PSIDr)
drop PSIDd PSIDr

*conspiracies
recode conspre* (1=5) (2=4) (4=2) (5=1)
alpha conspre*, item casewise gen(Conspre)
replace Conspre=(Conspre-1)/4

*trait aggression
recode BPAQ_1 BPAQ_3 BPAQ_4 BPAQ_5 (1=6) (2=5) (3=4) (4=3) (5=2) (6=1)
alpha BPAQ*, item casewise gen(TraitAgg)
replace TraitAgg=(TraitAgg-1)/5

*LL violence
recode llviolence_placebo_* (4=5) (5=4) (6=3) (7=2) (8=1)
recode llviolence_nocebo_* (4=5) (5=4) (6=3) (7=2) (8=1)

forval x=1/10 {
	egen LL`x'=rowfirst(llviolence_placebo_`x' llviolence_nocebo_`x')
}

alpha LL*, item casewise gen(LLsum)
replace LLsum=(LLsum-1)/4

forval x=1/10 {
egen ll_`x'=rowfirst(llviolence_placebo_`x' llviolence_nocebo_`x')
	recode ll_`x' 1/3=0 4/5=1, gen(lldi_`x')
}

*abstract violence - original items only
recode genviolence_for* (1=5) (2=4) (4=2) (5=1)
alpha genviolence_for*, item casewise gen(GenViolence)
replace GenViolence=(GenViolence-1)/4

*partisan violence
forval x=1/4 {
egen partyviolence`x'=rowfirst(partyviolence_d`x' partyviolence_r`x')
}

replace partyviolence1=(partyviolence1-1)/3
replace partyviolence2=(partyviolence2-1)/3
replace partyviolence3=(partyviolence3-1)/4
replace partyviolence4=(partyviolence4-1)/4

alpha partyviolence1-partyviolence4, item casewise gen(PartyViolence)

*dichotomous
recode genviolence_for_1 1/3=0 4/5=1, gen(gvdi1)
recode genviolence_for_2 1/3=0 4/5=1, gen(gvdi2)
recode genviolence_for_3 1/3=0 4/5=1, gen(gvdi3)

recode partyviolence1 .1/1=1, gen(pvdi1)
recode partyviolence2 .1/1=1, gen(pvdi2)
recode partyviolence3 .1/1=1, gen(pvdi3)
recode partyviolence4 .1/1=1, gen(pvdi4)

*knowledge
recode pk1 4=1 *=0
recode pk2 3=1 *=0
recode pk3 1=1 *=0
recode pk4 2=1 *=0
alpha pk*, item casewise gen(Know)
tab Know

*demos
recode race 2/5=0, gen(white)
recode sex 2/3=0, gen(male)

*general indicator of low-quality responding
gen satisficer=0 
replace satisficer=1 if Lowincidence>.2
replace satisficer=1 if trolling>.25
replace satisficer=1 if checkgrid==0
replace satisficer=1 if checkview==0


************
* analysis *
************


*demographics
tab sex
tab age
tab race
tab educ
tab pid
tab ideo


replace age=(age-2)/6


*do placebo items affect endorsement of violence?
ttest LLsum if llvalid==2, by(llplacebo)


*distribution of support for actions
gen llperc=.
gen llperc_lo=.
gen llperc_hi=.
forval x=1/10 {
	ci means lldi_`x' if llvalid==2
	replace llperc=r(mean) in `x'
	replace llperc_lo=r(lb) in `x'
	replace llperc_hi=r(ub) in `x'
}

gen x=_n
replace x=. if _n>10
recode x 1=1 2=2 3=4 4=6 5=5 6=8 7=7 8=3 9=9 10=10

twoway (bar llperc x, horiz xtitle("Proportion Supporting") ytitle("") legend(off) xlab(0(.1).3) ylab(1 "Kill" 2 "Hit with car" 4 "Throw rocks and bottles" 6 "Punch in the face" 5 "Brick through window" 7 "Graffiti car" 8 "Protest with weapons" 3 "Threatening messages" 9 "Share location" 10 "Curse in face") subtitle("Pilot Study (MTurk)") saving(pilot_ll_desc.gph, replace)) (rcap llperc_hi llperc_lo x, horiz)

graph combine pilot_ll_desc.gph fig2_si.gph 


*distribution of each measure of partisan violence
hist LLsum if llvalid==2, freq xtitle("Support for Aggression") subtitle("Most Harm (MTurk)") ylab(0(250)750) xlab(0(.25)1) saving(pilot_llhist.gph, replace)
hist GenViolence, freq xtitle("Support for Aggression") subtitle("Abstract (MTurk)") ylab(0(250)750) xlab(0(.25)1) saving(pilot_gvhist.gph, replace)
hist PartyViolence, freq xtitle("Support for Aggression") subtitle("Partisan (MTurk)") ylab(0(250)750) xlab(0(.25)1) saving(pilot_pvhist.gph, replace)
graph combine pilot_llhist.gph pilot_gvhist.gph pilot_pvhist.gph, rows(1) subtitle("Distribution of Support for Political Aggression")

*low-quality repsonding by scale
recode GenViolence 0=0 .01/1=1, gen(GV_di)
recode PartyViolence 0=0 .01/1=1, gen(PV_di)
recode LLsum 0=0 .01/1=1, gen(LL_di)

label define lab_vidi 0 "Rejects All Aggression" 1 "Does Not Reject", replace
label values GV_di PV_di LL_di lab_vidi

graph bar satisficer, over(GV_di, relabel(1 `""Rejects All" "Aggression""' 2 `""Does Not Reject" "All Aggression""')) saving(gv_opt.gph, replace) ytitle("Proportion")subtitle("Abstract") ylab(0(.1).4)

graph bar satisficer, over(PV_di, relabel(1 `""Rejects All" "Aggression""' 2 `""Does Not Reject" "All Aggression""')) saving(pv_opt.gph, replace) ytitle("Proportion")subtitle("Partisan")  ylab(0(.1).4)

graph bar satisficer, over(LL_di, relabel(1 `""Rejects All" "Aggression""' 2 `""Does Not Reject" "All Aggression""')) saving(ll_opt.gph, replace) ytitle("Proportion") subtitle("Most Harm") ylab(0(.1).4)

graph combine ll_opt.gph gv_opt.gph pv_opt.gph , rows(1)


*relationships between measures of political aggression
twoway scatter LLsum PartyViolence if llvalid==2, jitter(5) msize(small) mcol(%30) xtitle("Partisan Violence") ytitle("Most Harmful Actor") subtitle("") legend(off) || lowess LLsum PartyViolence, saving(ll_pv.gph, replace)

twoway scatter LLsum GenViolence if llvalid==2, jitter(5) msize(small) mcol(%30) xtitle("Abstract Violence") ytitle("Most Harmful Actor") subtitle("") legend(off) || lowess LLsum GenViolence, saving(ll_gv.gph, replace)

twoway scatter GenViolence PartyViolence if llvalid==2, jitter(5) msize(small) mcol(%30) xtitle("Partisan Violence") ytitle("Abstract Violence") subtitle("") legend(off) || lowess GenViolence PartyViolence, saving(gv_pv.gph, replace)

graph combine ll_gv.gph ll_pv.gph gv_pv.gph, rows(1) 


*who gives valid answer to most harmful actor?
recode llvalid 1=0 2=1, gen(llvalid01)
logit llvalid PID PSIDext satisficingindex Trollindex Know age white male


*factor structure of aggression
polychoric LL1-LL10 if llvalid==2
display r(sum_w)
global N=r(sum_w)
matrix r=r(R)
factormat r, n($N) 
factormat r, n($N) factors(1)


*predictors of support for violence
tobit LLsum PSID PSIDext ideoext Conspre TraitAgg satisficingindex_di Trollindex_di age white male if llvalid==2, ll(0) ul(1)
tobit GenViolence PSID PSIDext ideoext Conspre TraitAgg satisficingindex_di Trollindex_di age white male if llvalid==2, ll(0) ul(1)
tobit PartyViolence PSID PSIDext ideoext Conspre TraitAgg satisficingindex_di Trollindex_di age white male if llvalid==2, ll(0) ul(1)

